Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ecstatic

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecstatic

A simple static file server middleware

  • 4.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
440K
decreased by-20.4%
Maintainers
2
Weekly downloads
 
Created

What is ecstatic?

The 'ecstatic' npm package is a simple static file server middleware for Node.js. It allows you to serve static files with ease, making it useful for development and simple web servers.

What are ecstatic's main functionalities?

Basic Static File Serving

This feature allows you to serve static files from a specified directory. In this example, files from the 'public' directory will be served on port 8080.

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public' })
);
server.listen(8080);

Custom Error Pages

This feature allows you to handle errors and serve custom error pages. In this example, a custom 404 error page is served when a file is not found.

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public', handleError: false })
);
server.on('request', (req, res) => {
  res.on('error', (err) => {
    res.writeHead(404, { 'Content-Type': 'text/html' });
    res.end('<h1>Custom 404 Page</h1>');
  });
});
server.listen(8080);

Cache Control

This feature allows you to set cache control headers for the served files. In this example, the cache is set to expire in 3600 seconds (1 hour).

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public', cache: 'max-age=3600' })
);
server.listen(8080);

Other packages similar to ecstatic

Keywords

FAQs

Package last updated on 01 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc